package com.yupi.usercenter.once;

import com.alibaba.excel.EasyExcel;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ImportDatabase {


    public static void main(String[] args) {
        String fileName = "D:\\demo\\myLearn\\user-center-backend\\src\\main\\resources\\testExcel.xls";
        // 这里 需要指定读用哪个class去读，然后读取第一个sheet 同步读取会自动finish
        List<PlanetInfo> list = EasyExcel.read(fileName).head(PlanetInfo.class).sheet().doReadSync();.

        System.out.println(String.format("总数：%s", list.size()));


        Map<String, List<PlanetInfo>> collect = list.stream().filter(l-> StringUtils.isNotEmpty(l.getUsername())).collect(Collectors.groupingBy(PlanetInfo::getUsername));

        System.out.println(String.format("不重名的昵称数:%s", collect.keySet().size()));
    }

}
